﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using StudentManagement.Data;
using StudentManagement.Models;
using StudentManagement.Repositories;

namespace StudentManagementSystem.Repositories
{
    public class LogRepository : ILogRepository
    {
        private readonly SchoolDbContext _context;

        public LogRepository(SchoolDbContext context)
        {
            _context = context;
        }

        public async Task AddLogAsync(Log log)
        {
            _context.Logs.Add(log);
            await _context.SaveChangesAsync();
        }

        public async Task<IEnumerable<Log>> GetLogsAsync()
        {
            return await _context.Logs.ToListAsync();
        }

        public async Task<Log> GetLogAsync(int id)
        {
            return await _context.Logs.FindAsync(id);
        }
    }
}